/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Hola;

/**
 *
 * @author luisorozco
 */
import javax.microedition.lcdui.Command; 
import javax.microedition.lcdui.CommandListener; 
import javax.microedition.lcdui.Display; 
import javax.microedition.lcdui.Displayable; 
import javax.microedition.lcdui.Form; 
import javax.microedition.lcdui.TextBox; 
import javax.microedition.lcdui.TextField; 
import javax.microedition.midlet.MIDlet;

/** 
This MIDlet demonstrates use of the MIDP UI TextBox 
Displayable. 
98 
@see javax.microedition.lcdui.TextBox 
*/ 
public class TextBoxDemo extends MIDlet 
implements CommandListener 
{ 
private Command quit = 
new Command("Exit", Command.EXIT, 1); 
private static TextBoxDemo instance; 
// The TextBox UI component. 
private TextBox textBox; 
// The maximum number of characters that the TextBox can 
// hold. 
private int MAX_SIZE = 100; 
// The TextBox's initial text. 
private String initialText = 
"You can edit the contents of this TextBox";

/** 
Constructor. 
*/ 
public TextBoxDemo() 
{ 
super(); 
instance = this; 
} 
public void pauseApp() 
{ 
} 
public void destroyApp(boolean destroy) 
{ 
textBox = null; 
initialText = null; 
instance = null; 
} 
void quit() 
{ 
destroyApp(true); 
notifyDestroyed(); 
} 
public void startApp() 
{ 
textBox = new TextBox("A TextBox", "", 1, 0); 
textBox.addCommand(quit); 
textBox.setCommandListener(this); 
display(); 
}

/** 
Returns the single instance of this class. Calling 
this method before constructing an object will return 
a null pointer. 
@return an instance of this class. 
*/ 
public static TextBoxDemo getInstance() 
{ 
    return instance; 
} 
public void display() 
{ 
    Display.getDisplay(this).setCurrent(textBox); 
} 
public void commandAction(Command c, Displayable d) 
{ 
    if (c == quit) 
    { 
    quit(); 
    } 
} 
}